<?php
/* 
* @Title:  [订单模型]
* @Author: {chenlei} [chenleib5@126.com]
* @Date:   2014-04-17 11:22:24
* @Last Modified by:   Administrator
* @Last Modified time: 2014-04-22 11:18:21
* @Copyright:  [hn7m.com]
*/
class OrderModel extends Model{
	public $table='order';

	//自动验证
	public $validate=array(
		array('consignee','nonull','收货人姓名不能为空',2,3)
		);
	/**
	 * [add_data 添加数据]
	 */
	public function add_data($data){
		return $oid=$this->add($data);
	}
	/**
	 * [del_data 删除数据]
	 * @param  [type] $where [description]
	 * @return [type]        [description]
	 */
	public function del_data($where){
		return $this->where($where)->del();
	}
	/**
	 * [update_data 更新数据]
	 * @param  [type] $where [description]
	 * @param  [type] $data  [description]
	 * @return [type]        [description]
	 */
	public function update_data($where,$data){
		return $this->where($where)->save($data);
	}
	/**
	 * [get_data 获得所有订单数据]
	 * @return [type] [description]
	 */
	public function get_data($where=NULL){
		return $this->where($where)->findAll();
	}
	/**
	 * [get_one_value 获得一条记录值]
	 * @param  [type] $where [description]
	 * @param  [type] $field [description]
	 * @return [type]        [description]
	 */
	public function get_one_value($where,$field){
		return $this->where($where)->getField($field);
	}
	/**
	 * [get_one_data 获得一条记录]
	 * @param  [type] $where [description]
	 * @return [type]        [description]
	 */
	public function get_one_data($where){
		return $this->where($where)->find();
	}
	/**
	 * [update_state 更新订单状态]
	 * @return [type] [description]
	 */
	public function update_state($oid,$state){
		return $this->where(array('oid'=>$oid))->save(array('ostate'=>$state));
	}
	/**
	 * [get_num 按字段计数]
	 * @return [type] [description]
	 */
	public function get_num($where){
		return $this->where($where)->count();
	}
}
?>